#!/usr/bin/python3
# -*- coding: UTF-8 -*-

import datetime
import time

a = time.time()
start = datetime.datetime.now()
time.sleep(3)
end = datetime.datetime.now()
b = time.time()

print((end-start).days) # 0 天数
print('ms:', (end-start).total_seconds() * 1000) 
print((end-start).seconds)
# 在mongo-test.py 中micro又指 us ??????????????
print((end-start).microseconds)  # 这获取的是 总时间中微秒的部分,并不是指以微秒为单位的总时间
print("b-a", b-a)

now = datetime.datetime.now()
three_days_ago = now + datetime.timedelta(days=-3)
three_weeks_ago = now + datetime.timedelta(weeks=-3)

print('now', now) # datetime.datetime(2016, 12, 22, 11, 24, 49, 987171)
print(three_days_ago) # datetime.datetime(2016, 12, 19, 11, 24, 49, 987171)
print(three_weeks_ago) # datetime.datetime(2016, 12, 1, 11, 24, 49, 987171)
